<template>
  <div class="moreTaskCreate z-h-100">
     <listFilter
        :fields="cFormData"
        :highSearchFile="highSearchFile"
        @getList="getList"
        ref="listFilter"
        :leftToolToolData="leftToolToolData"
      >
      </listFilter>
  </div>
</template>

<script>
import { getPlanPage, getUserSelect } from "@/api/workBeach/moreTaskCreate";
import listFilter from "@/components/listFilter";
import { remote } from "@/api/admin/dict";
export default {
  name: "moreTaskCreate",
  async created () {
    this.statusOptions = await this.getRemoteFun("plan_status");
  },
  components: {
    listFilter
  },
  computed: {
    cFormData () {
      let formData = [
        { label: "计划名称", placeholder: "请输入任务名称", type: "el-input", props: { clearable: true }, prop: "name" },
        { label: "计划状态", placeholder: "请选择状态", type: "el-select", props: { clearable: true, filterable: true }, prop: "status", options: [] },
        { label: "是否公开", placeholder: "请选择是否公开", props: { clearable: true, filterable: true }, prop: "isOpen" },
        { label: "创建人工号", prop: "srcId" },
        { label: "创建人", prop: "createdBy" },
        { label: "版本", prop: "version" },
        { label: "类型", prop: "type" },
        { label: "创建时间", prop: "createdTime" },
        { label: "是否公开", prop: "isPublic" }
      ];
      let target = formData.find(v => v.prop === "status");
      this.$set(target, "options", this.statusOptions);
      return formData;
    }
  },
  data () {
    return {
      highSearchFile: [
        { label: "计划名称", placeholder: "请输入任务名称", type: "el-input", props: { clearable: true }, prop: "name" },
        { label: "状态", placeholder: "请选择状态", type: "el-select", props: { clearable: true, filterable: true }, prop: "status", options: [] },
        { label: "是否公开", placeholder: "请选择是否公开", type: "el-select", props: { clearable: true, filterable: true }, prop: "isOpen", options: [{ label: "是", value: "1" }, { label: "否", value: "0" }] }
      ],
      height: 400,
      leftToolToolData: [
        { text: "新增", click: this.addFun },
        { text: "修改", click: this.addFun },
        { text: "复制", click: this.addFun },
        { text: "发布", click: this.addFun },
        { text: "删除", click: this.addFun },
        { text: "查看", click: this.addFun },
        { text: "终止", click: this.addFun }
      ],
      total: 0,
      params: {
        current: 1,
        size: 10
      },
      getUserSelect,
      statusOptions: []
    };
  },
  methods: {
    addFun () {
      console.log("add");
    },
    // 获取字典
    getRemoteFun (type) {
      return new Promise(resolve => {
        remote(type).then(res => {
          resolve(res.data.data);
        });
      });
    },
    // 获取table数据
    getList (index, size, query, cb) {
      const params = {
        current: index,
        size: size
      };
      Object.assign(params, query);
      getPlanPage(params).then(res => {
        console.log(res);
        if (res.data.code === 0) {
          let map = {
            total: res.data.data.total,
            list: res.data.data.records
          };
          cb(map);
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>

.moreTaskCreate{
  background-color:#fff;
  position: relative;
  .toolbar{
    width: 100%;
    height:40px;
    display: flex;
    align-items: center;
    padding-left: 10px;
  }
  .moreTaskCreate-table{
    padding-top:57px;
    height: calc(100% - 40px - 60px);
  }
  .moreTaskCreate-portalPagination{
    text-align: right;
  }
}
</style>